package com.SinaMicroblogging.Extension;

import java.io.IOException;
import java.util.List;

import com.SinaMicroblogging.R;
import com.SinaMicrobloggingApi.Model.DirectMessagesModel;
import com.SinaMicrobloggingApi.Model.StatusModel;
import com.SinaMicrobloggingApi.Model.UserInfoModel;
import com.Util.HttpUtility;
import com.Util.String2;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.Html;
import android.text.TextUtils.TruncateAt;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.RelativeLayout.LayoutParams;

public class UserInfoItemAdapter extends BaseAdapter {

	private List<String> userInfos;
	private LayoutInflater layoutInflater;

	public UserInfoItemAdapter(List<String> userInfos, Context context) {
		this.userInfos = userInfos;
		layoutInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return userInfos == null ? 0 : userInfos.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return userInfos.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder viewHolder;
		if (convertView == null) {
			convertView = layoutInflater.inflate(R.layout.userinfoitemview,
					null);
			viewHolder = new ViewHolder();
			viewHolder.avatar = (ImageView) convertView
					.findViewById(R.id.avatar);
			viewHolder.title = (TextView) convertView.findViewById(R.id.title);
			viewHolder.info = (TextView) convertView.findViewById(R.id.info);
			convertView.setTag(viewHolder);

		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		String[] strInfos = userInfos.get(position).split("_");
		viewHolder.title.setText(strInfos[0]);
		viewHolder.info.setText(strInfos[1]);
		return convertView;
	}

	static class ViewHolder {
		ImageView avatar;
		TextView title;
		TextView info;
	}
}
